using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AppTableUtils;

public class TestReadTable : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        string file_name = "student.csv";  // 发布安卓和ios的话, 多段兼容考虑, 更推荐使用csv格式
        // string file_name = "student.xlsx";  // win打包后报错的问题: https://blog.csdn.net/qq_33789001/article/details/115369284
        
        string dir_path = BdUtils.data_table_dir_path;
        string f_path = BdUtils.join(dir_path, file_name);
        
        var dt = TableUtils.read_table(f_path);
        TableUtils.show_data_table(dt, zh_len: 10);

        var dc = TableUtils.conv_row_to_dc(dt.Rows[0]);
        BdUtils.log(dc);

        var age = BdUtils.conv_to_int(dc["年龄"]);
        var student_name = BdUtils.conv_to_string(dc["姓名"]);
        var score = BdUtils.conv_to_float(dc["得分"]);
        BdUtils.log($"name: {student_name}, age: {age}, score: {score}");
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
